﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Data.SqlClient;
using Net7Music_Api.Model;

namespace Net7Music_Api.DAL
{
    public class SongServces
    {
        //最新最热的10条数据
        public static List<SongQuantity10_Result> SongQuantity10()
        {
            string sql = "EXEC GetSongQuantity";

            SqlDataReader dr = DBHelper.GetDataReader(sql);
            List<SongQuantity10_Result> Songlists = new();
            while (dr.Read())
            {
                SongQuantity10_Result Song = new()
                {
                    //overid = (int)dr.GetInt64(0),
                    SongID = dr.GetInt32(0),
                    SongName = dr.GetString(1),
                    SongAddress = dr.GetString(2),
                    SingerName = dr.GetString(3),
                };
                Songlists.Add(Song);
            }
            dr.Close();
            return Songlists;
        }
        //最新最热的6条歌曲数据
        public static List<Song> SongTimeQuantity()
        {
            string sql = "select top 6 SongID,SongPicture from Song order by SongTime,Quantity desc";
            SqlDataReader dr = DBHelper.GetDataReader(sql);
            List<Song> Songlists = new();
            while (dr.Read())
            {
                Song Song = new()
                {
                    SongID = dr.GetInt32(0),
                    SongPicture = dr.GetString(1),
                };
                Songlists.Add(Song);
            }
            dr.Close();
            return Songlists;
        }
    }
}
